#ifndef IMAGEPROCESSOR_H
#define IMAGEPROCESSOR_H

#include <QObject>
#include <QImage>
#include <QQuickImageProvider>
#include <opencv2/opencv.hpp>

class ImageProcessor : public QObject
{
    Q_OBJECT
public:
    explicit ImageProcessor(QObject *parent = nullptr);

    Q_INVOKABLE QImage detectEdges(const QString &imagePath);

private:
    cv::Mat qImageToMat(const QImage &image);
    QImage matToQImage(const cv::Mat &mat);
};

class EdgeDetectionProvider : public QQuickImageProvider
{
public:
    EdgeDetectionProvider(ImageProcessor *processor);
    QImage requestImage(const QString &id, QSize *size, const QSize &requestedSize) override;

private:
    ImageProcessor *m_processor;
};

#endif // IMAGEPROCESSOR_H
